home *** CD-ROM | disk | FTP | other *** search
- #define ALLOCATE_GLOBALS 1
- #include "defs.h"
-
- #include <Traps.h>
- #include "patching.h"
- #include "Prefs.h"
- #include "Copy text.h"
- #include "FixPC.h"
-
- #define ToolScratch 0x09CE // an 8-byte scratch area in low memory
-
- void Select_rect( Rect *result );
-
- #define CAPSLOCK_KEY 0x39
- #define CONTROL_KEY 0x3B
-
- #define MEM_RESOURCE 0x20
-
- pascal void main( void )
- {
- GrafPtr save_port;
- Ptr my_p;
- SignedByte my_state;
- OSErr err;
- ProcPtr FKEY_p;
-
- asm {
- bra.S @afterheader
- DC.W 0
- DC.L 'FKEY'
- DC.W 6
- DC.W 0
- @afterheader
- movem.l a0-a5/d0-d7, -(SP) ; save registers
- FIXPC ; StripAddress
- LEA main, A4 ; set up globals
- move.L A4, my_p
- }
-
- front = FrontWindow();
- if (front == NIL)
- goto getout;
- GetPort( &save_port );
- SetPort( front );
-
- my_h = RecoverHandle(my_p);
- if (MemError() != noErr) DebugStr("\pRecoverHandle error code");
- my_state = HGetState( my_h );
- if (my_state & MEM_RESOURCE) // Is this the FKEY...
- {
- if ( KeyIsDown( CAPSLOCK_KEY ) || KeyIsDown( CONTROL_KEY ) )
- {
- Get_prefs( p_leave_open, my_h );
- Configure_dialog( );
- CloseResFile( pref_resfile );
- }
- else
- {
- Get_prefs( p_read_only, my_h );
- switch (copy_mode)
- {
- case c_all:
- Copy_text = Copy_all_text;
- selected_rect = front->portRect;
- break;
- case c_window:
- Copy_text = Copy_window_text;
- selected_rect = front->portRect;
- break;
- case c_selected:
- Copy_text = Copy_selected_text;
- Select_rect( &selected_rect );
- GlobalToLocal( &topLeft(selected_rect) );
- GlobalToLocal( &botRight(selected_rect) );
- break;
- }
- if (!EmptyRect(&selected_rect))
- {
- err = HandToHand( &my_h ); // clone this resource
- if (err == noErr)
- {
- HLock( my_h );
- FKEY_p = (ProcPtr) StripAddress( *my_h );
- (*(pascal void (*)(void))FKEY_p)();
- }
- }
- } // not configuring
- }
- else // ... or the copy?
- {
- InvalRect( &selected_rect );
- PATCH( BeginUpDate );
- PATCH( EndUpDate );
- }
-
- SetPort( save_port );
- getout:
- asm {
- movem.l (SP)+, a0-a5/d0-d7
- }
- }